<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
div {width:200px; height:200px; float:left; border:1px solid black; margin:10px;}
</style>
<script>
window.onload=function ()
{
	var aDiv=document.getElementsByTagName('div');
	
	//alert(aDiv.length);
	//aDiv.style.background='red';
	
	for(var i=0;i<aDiv.length;i++)
	{
		//i->0,1,2,3
		aDiv[i].style.background='red';
	}
	
	/*
	aDiv[0].style.background='red';
	aDiv[1].style.background='red';
	aDiv[2].style.background='red';
	aDiv[3].style.background='red';
	*/
};
</script>
</head>

<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
